package org.zxyj.manage.thread;

import java.util.concurrent.atomic.AtomicInteger;

public class WorkThread extends Thread {
	private Runnable target; // 线程执行目标
    private AtomicInteger counter;
    long freeMem = Runtime.getRuntime().freeMemory();
    public WorkThread(Runnable target, AtomicInteger counter) {
        this.target = target;
        this.counter = counter;
    }

    @Override
    public void run() {
        try {
            target.run();
        } catch(Exception ex){
            int c1 = counter.getAndDecrement();
            //System.out.println("------------------------WorkThread terminate no " + c1 + " Threads "+target);
        }
    }
}
